﻿using Application.Behaviors;
using FluentValidation;
using Mediator;
using Microsoft.Extensions.DependencyInjection;

namespace Application;

public static class DependencyInjection
{
    public static IServiceCollection AddApplication(this IServiceCollection services)
    {
        services.AddMediator(config =>
        {
            config.NotificationPublisherType = typeof(TaskWhenAllPublisher);
            config.Namespace = "Application";
            config.PipelineBehaviors = [typeof(LoggingPipelineBehavior<,>), typeof(ValidationPipelineBehavior<,>)];
            config.ServiceLifetime = ServiceLifetime.Scoped;
        });
        services.AddValidatorsFromAssembly(typeof(DependencyInjection).Assembly, includeInternalTypes: true);
        return services;
    }
}
